package com.zxcz.tools;

import com.zxcz.domain.Result;

/**
 * 返回结果的数据结构封装
 * @author root
 */
public class ResultUtil {
    
    public static Result<Object> generate(CustomHttpStatus customHttpStatus, Object object){
    	Result<Object> result = new Result<>();
        result.setCode(customHttpStatus.getValue());
        result.setMessage(customHttpStatus.getReasonPhrase());
        result.setData(object);
        return result;
    }
    
    public static Result<Object> generate(Integer code, String message, Object object){
        Result<Object> result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        result.setData(object);
        return result;
    }
    
	public static Result<Object> generate(CustomHttpStatus customHttpStatus){
		Result<Object> result = new Result<>();
        result.setCode(customHttpStatus.getValue());
        result.setMessage(customHttpStatus.getReasonPhrase());
        return result;
	}
	
	public static Result<Object> generate(Integer code, String message){
		Result<Object> result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        return result;
	}
	
}
